package com.ny.demo526;

import java.util.List;

public class TestSet {
    public void addEmp(List<Emp>list,Emp emp){
        list.add(emp);
    }
    public void findAllEmp(List<Emp> list){
        for (int i = 0;i < list.size();i++){
            System.out.println(list.get(i));
        }
    }
    public void findEmpName(List<Emp> list,String name){
        for (int i = 0;i < list.size();i++){
            if (name.equals(list.get(i).getName())){
                System.out.println(list.get(i));
            }
        }
    }
    public void deleteEmpNumber(List<Emp> list,String number){
        for (int i = 0;i < list.size();i++){
            if (number.equals(list.get(i).getNumber())){
                list.remove(i);
                System.out.println(list);
            }
        }
    }
    public Emp findEmpNumber(List<Emp> list,String number){
        for (int i = 0;i < list.size();i++){
            if (number.equals(list.get(i).getNumber())){
                return list.get(i);
            }
        }
        return null;
    }
    public void updateEmpAge(List<Emp> list,Emp emp){
        for (int i = 0;i < list.size();i++){
            if (emp.getNumber().equals(list.get(i).getNumber())){
                list.get(i).setAge(emp.getAge());
                System.out.println(list);
            }
        }
    }
}